<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorate="~{admin/fragments/layout}"
	th:with="title='用户管理',active='user'">

<section layout:fragment="header">
	<h1>用户管理</h1>
</section>

<section layout:fragment="content">

	<div class="box box-primary">
		<div class="box-header">
			<a class="btn btn-sm btn-success" href="/admin/user/add">新增</a>
		</div>
		<div class="box-body">
			<table id="userTab" class="table table-bordered table-striped">
				<thead>
					<tr>
						<th>用户编号</th>
						<th>用户名</th>
						<th>性别</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<tr th:each="user : ${list}">
						<td th:text="${user.id}"></td>
						<td th:text="${user.userName}"></td>
						<td th:text="${user.sex}"></td>
						<td><a class="btn btn-sm btn-success"
							th:href="@{'/admin/user/edit/'+${user.id}}">修改</a>
							<a class="btn btn-sm btn-warning" th:href="@{'/admin/user/grant/'+${user.id}}">分配角色</a>
							<button class="btn btn-sm btn-danger"
								th:onclick="'del('
									+ ${user.id}
									+ ')'">删除</button></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</section>
<script layout:fragment="script">
	$(document).ready(function() {
		var tab = $('#userTab').DataTable({
			language : {
				url : '/assets/plugins/datatables.net/Chinese.json'
			},
			processing : true,
			serverSide : false,
			order : [ [ 0, "asc" ] ],
			columnDefs : [ {
				"orderable" : false,
				"targets" : -1
			}, {
				"searchable" : false,
				"targets" : -1
			} ]
		});
	});
</script>
</html>